package com.nancy.java_design.iterator.demo1;

/**
 * 迭代器模式
 */
public class Client {
    public static void main(String[] args) {
        // 创建学生容器对象
        StudentContainer studentContainer = new StudentContainerImpl();

        // 添加学生
        studentContainer.addStudent(new Student("张三", "001"));
        studentContainer.addStudent(new Student("李四", "002"));
        studentContainer.addStudent(new Student("王五", "003"));

        // 获取学生迭代器
        StudentIterator studentIterator = studentContainer.getStudentIterator();
        while (studentIterator.hasNext()) {
            System.out.println(studentIterator.next());
        }

    }
}
